﻿#ifndef UICUSTOMDIALOG_H
#define UICUSTOMDIALOG_H

#include <QDialog>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QPushButton>
#include <QEventLoop>


class UiCustomDialog : public QWidget
{
    Q_OBJECT
public:
    enum EAcctype{
        Accepted = 0x00
    };
    explicit UiCustomDialog(QWidget *parent = nullptr);
    ~ UiCustomDialog();

    void setConten(QLayout* layout);
    void setConten(QWidget* widget);

    int exec() {
        this->show();
        int ret = loop->exec(); // 启动事件循环
        return ret;
    }

signals:
    void accepted();
    void rejected();

public slots:
    void accept() {
        emit accepted();
        loop->quit(); // 退出事件循环
    }

    void reject() {
        emit rejected();
        loop->quit(); // 退出事件循环
    }

private:
    QEventLoop *loop;

    QVBoxLayout m_mainLayout;
    QVBoxLayout m_contentLayout;
    QHBoxLayout m_buttonLayout;
    QPushButton m_accept;
    QPushButton m_exit;
};

#endif // UICUSTOMDIALOG_H
